package com.whj.serviceorder.controller;

import com.whj.serviceorder.entity.OrderInfo;
import com.whj.serviceorder.mapper.OrderInfoMapper;
import com.whj.serviceorder.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: wanghaijun
 * @Date: 2023/2/18 - 02 - 18 - 20:21 
 * @Description: com.whj.serviceorder.controller
 */

@RestController
public class testController {


    @Autowired
    OrderInfoMapper orderInfoMapper;
    @Autowired
    OrderInfoService orderInfoService;
    @Value("${server.port}")
    String port;

    /**
     * 测试派单逻辑
     *
     * @param orderId
     * @return
     */
    @GetMapping("/test/{orderId}")
    public String dispatchRealTimeOrder(@PathVariable("orderId") Long orderId){

        System.out.println("Server-order的端口为："+port+",并发请求的orderId = " + orderId);
        OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
        orderInfoService.dispatchRealTimeOrder(orderInfo);
        return "success";
    }
}
